package cn.mapper;

import cn.entity.SysResource;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface SysResourceMapper extends Mapper<SysResource> {
    @Select("SELECT srr.role_id,sr.* FROM sys_role_resource srr left join sys_resource sr on srr.resource_id=sr.id WHERE sr.type=0 and srr.del_flag =0 and role_id =#{id} ORDER BY id ")
    List<SysResource> selectResourceByRid(Long id);

    @Select("SELECT url FROM sys_resource WHERE type=0 and del_flag =0")
    List<SysResource> selectResources();

    @Select("SELECT sr.url FROM sys_role_resource srr left join sys_resource sr on srr.resource_id=sr.id WHERE sr.type=0 and srr.del_flag =0 and role_id =(SELECT role_id FROM sys_user_role WHERE user_id =#{id}) ORDER BY sr.id ")
    List<String> selectResourceByUid(Long id);

}